package com.example.registerstarter.listener;

import com.example.registerstarter.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class AppStartupListener implements ApplicationListener<ApplicationReadyEvent> {

    @Autowired
    private RegisterService registerService;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        System.out.println("Spring Boot application has started!");
        // 注册
        registerService.addObserver();
    }
}